package com.example.presentshopping.ui.activity

import android.os.Bundle
import androidx.fragment.app.Fragment
import com.example.presentshopping.R
import com.example.presentshopping.config.base.BaseMvpActivity
import com.example.presentshopping.ui.fragment.PromoteOrder.StartersFragment
import com.example.presentshopping.utils.ToastUtil
import com.example.presentshopping.exent.UserEvent
import com.example.presentshopping.ui.fragment.PromoteOrder.StarterstowFragment
import kotlinx.android.synthetic.main.activity_promote_order.*
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe

//我的团队
class PromoteOrderActivity : BaseMvpActivity() {
    private val strTitle = arrayOf("一级推广", "二级推广")

    override val layoutId: Int
        get() = R.layout.activity_promote_order

    override fun initView(savedInstanceState: Bundle?) {

        EventBus.getDefault().register(this)
        val pageViews = ArrayList<Fragment>()
        pageViews.add(StartersFragment("1"))
        pageViews.add(StarterstowFragment("2"))
        tablayout.setViewPager(SpecialViewPager, strTitle, this, pageViews)
        title_main_tv.leftBackImageTv.setOnClickListener { finish() }

    }
    @Subscribe
    fun onEventMainThread(event : UserEvent){
        balance_textview_01.text = event.num
        balance_textview_05.text =when(event.grade){
            "0"->"普通"
            "1" -> "青铜"
            "2"->"王者"
            "3"->"至尊"
            else ->""
        }
        balance_textview_07.text = event.firstyesterdaytotal
        balance_textview_08.text =event.secondyesterdaytotal

    }

    override fun onDestroy() {
        super.onDestroy()
        EventBus.getDefault().unregister(this)
    }

    override fun showToast(msg: String?) {
        ToastUtil.showMsg(msg)
    }

    override fun onSuccess(data: String?) {



    }

    override fun onFailure(e: Throwable?, code: Int, msg: String?, isNetWorkError: Boolean) {

    }
}